package com.lovo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lovo.model.CommodityOrder;
import com.lovo.service.CommodityOrderService;
import com.lovo.util.MyUtils;
import com.lovo.VO.CommodityOrderVo;
import com.lovo.VO.ServiceOrderVo;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class CommodityOrderServiceImpl implements CommodityOrderService {

    SqlSession sqlSession = MyUtils.getSqlSession();
    @Override
    public int deleteByPrimaryKey(Integer commodityOrderId) {
        return 0;
    }

    @Override
    public int insert(CommodityOrder record) {
        return 0;
    }

    @Override
    public int insertSelective(CommodityOrder record) {
        return 0;
    }

    @Override
    public ServiceOrderVo selectByPrimaryKey(Integer commodityOrderId) {
        String stmt="com.lovo.dao.CommodityOrderMapper.selectByPrimaryKey";
        return sqlSession.selectOne(stmt,commodityOrderId);
    }

    @Override
    public int updateByPrimaryKey(CommodityOrderVo record) {
        String stmt = "com.lovo.dao.CommodityOrderMapper.updateByPrimaryKey";
        int n=sqlSession.update(stmt,record);
        sqlSession.commit();
        return n;
    }

    @Override
    public PageInfo<CommodityOrderVo> selectAll(CommodityOrderVo com,int pageNo,int pageSize) {
        String stmt = "com.lovo.dao.CommodityOrderMapper.selectAll";
        //注意：这句话一定要放在读取数据的前面，才能实现拦截
        PageHelper.startPage(pageNo,pageSize);
        List<CommodityOrderVo> commodityOrderVo=sqlSession.selectList(stmt,com);
        sqlSession.commit();
        //将集合对象放入到PageInfo中
        PageInfo<CommodityOrderVo> page = new PageInfo<CommodityOrderVo>(commodityOrderVo);
        return page;
    }
}
